import Vue from 'vue'
import VueRouter from 'vue-router'

const Index = () =>import("../views/layout/Index");
const LoginIndex = () =>import("../views/login/Index");

Vue.use(VueRouter)

const routes = [

    //登陆注册主界面
    {
        path: '/',
        component:LoginIndex,
        name: 'loginIndex',
        meta:{
            title:"ruoyi登录注册"
        },
        children:[
            {
                path:'',
                redirect:'/login'
            },

            {
                path:'/login',
                component:()=> import("../views/login/Login")
            },

            {
                path:'/register',
                component:()=>import("../views/login/Register")
            }
        ]
    },

    //主页
    {
        path: '/index',
        component:Index,
        name: "index",
        children: [

        ]
    }

]

const router = new VueRouter({
  routes
})

//路由前置守卫 -- 进入之前先到这里
router.beforeEach((to, from, next)=>{
  if(to.path === "/"){
      window.document.title = to.meta.title;
  }
  next();
});


export default router
